﻿using System;
using System.Collections;
using System.Xml;

namespace WeiSha.Core
{
	// Token: 0x0200000F RID: 15
	public class CustomConfig : IEnumerable
	{
		// Token: 0x17000018 RID: 24
		// (get) Token: 0x0600005C RID: 92 RVA: 0x00004010 File Offset: 0x00002210
		// (set) Token: 0x0600005D RID: 93 RVA: 0x0000402D File Offset: 0x0000222D
		public string XmlString
		{
			get
			{
				return this.xmldoc.InnerXml;
			}
			set
			{
				this._xml = value;
			}
		}

		// Token: 0x17000019 RID: 25
		// (get) Token: 0x0600005E RID: 94 RVA: 0x00004038 File Offset: 0x00002238
		public CustomConfigItem Items
		{
			get
			{
				return this._items;
			}
		}

		// Token: 0x0600005F RID: 95 RVA: 0x00004050 File Offset: 0x00002250
		public CustomConfig()
		{
			string text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
			text += "<items/>";
			this._xml = text;
			this.xmldoc.LoadXml(this._xml);
			XmlNode lastChild = this.xmldoc.LastChild;
			this._items = new CustomConfigItem(lastChild);
		}

		// Token: 0x06000060 RID: 96 RVA: 0x000040B4 File Offset: 0x000022B4
		public CustomConfig(string xml)
		{
			bool flag = !string.IsNullOrWhiteSpace(xml);
			if (flag)
			{
				this._xml = xml;
				this.xmldoc.LoadXml(this._xml);
				XmlNode lastChild = this.xmldoc.LastChild;
				this._items = new CustomConfigItem(lastChild);
			}
		}

		// Token: 0x06000061 RID: 97 RVA: 0x00004114 File Offset: 0x00002314
		public static CustomConfig Load(string xml)
		{
			bool flag = !string.IsNullOrWhiteSpace(xml);
			CustomConfig customConfig;
			if (flag)
			{
				customConfig = new CustomConfig(xml);
			}
			else
			{
				customConfig = new CustomConfig();
			}
			return customConfig;
		}

		// Token: 0x06000062 RID: 98 RVA: 0x0000414C File Offset: 0x0000234C
		public static CustomConfig Load()
		{
			return new CustomConfig();
		}

		// Token: 0x1700001A RID: 26
		public CustomConfigItem this[string key]
		{
			get
			{
				return this._items.ChildSingle(key);
			}
		}

		// Token: 0x06000064 RID: 100 RVA: 0x00004182 File Offset: 0x00002382
		public IEnumerator GetEnumerator()
		{
			bool flag = this._items.Childs != null;
			if (flag)
			{
				int num;
				for (int i = 0; i < this._items.Childs.Length; i = num + 1)
				{
					yield return this._items.Childs[i];
					num = i;
				}
			}
			yield break;
		}

		// Token: 0x0400001D RID: 29
		private XmlDocument xmldoc = new XmlDocument();

		// Token: 0x0400001E RID: 30
		private string _xml;

		// Token: 0x0400001F RID: 31
		private CustomConfigItem _items;
	}
}
